﻿using BLL.Organization;
using BLL.Origins;
using Enums;
using Enums.Sys;
using Model.Origins;
using Model.Sys;
using PagedList;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DAGG.Controllers.Origins
{
    public class QueryLogController : BaseController
    {
        EnterpriseBLL bll0 = new EnterpriseBLL();
        QueryLogBLL bll = new QueryLogBLL();
        //
        // GET: /QueryLog/
        public ActionResult Index(int page = 1)
        {
            SysUserModel userModel = base.GetUserInfo();
            var enterId = userModel.EnterpriseId;
            string strWhere = string.Empty;
            //递归获取其所属子公司和子公司的子公司
            if (EnumManagement.GetEnumValue(SysRoleEnum.SuperManageRole) == userModel.RoleId)//管理员角色 查看全部
                strWhere += "  ";
            else
            {
                var listWhere = string.Join(",", bll0.GetSonEnterprise(userModel.EnterpriseId).Select(obj => obj.ID));
                if (string.IsNullOrEmpty(listWhere))
                    strWhere += " and (aq.EnterpriseId  in (0))";
                else
                    strWhere += " and (aq.EnterpriseId in (" + listWhere + "))";
            }


            
            IPagedList<QueryLogModel> sysUserList = bll.GetList(strWhere).ToPagedList(page, 10);
            ViewBag.MyPageList = sysUserList;
            return View();
        }
	}
}